package org.jeecg.modules.yw.utils;

import org.apache.shiro.SecurityUtils;
import org.jeecg.common.system.api.ISysBaseAPI;
import org.jeecg.common.system.util.JwtUtil;
import org.jeecg.common.system.vo.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

@Component
public class UserUtil {

    public static String getUserId(HttpServletRequest request,ISysBaseAPI sysBaseAPI) {
        String currentUserName = JwtUtil.getUserNameByToken(request);
        LoginUser sysUser = sysBaseAPI.getUserByName(currentUserName);
        return sysUser.getId();
    }
    public static String getUserName(HttpServletRequest request) {
        String currentUserName = JwtUtil.getUserNameByToken(request);
        return currentUserName;
    }
}
